﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Xml.Serialization;
using FlashCards.Dto;

namespace FlashCards.Service.Serialization
{
    public class DataSerializer
    {
        //public static string SerializeUser(User user)
        //{
        //    var writer = new StringWriter();
        //    var serializer = new XmlSerializer(typeof(User));
        //    serializer.Serialize(writer, user);
        //    return writer.ToString();
        //}

        //public static string SerializeCategories(List<Category> categories)
        //{
        //    var writer = new StringWriter();
        //    var serializer = new XmlSerializer(typeof(List<Category>));
        //    serializer.Serialize(writer, categories);
        //    return writer.ToString();
        //}

        public static string SerializeDto(object dto, Type dtoType)
        {
            var writer = new StringWriter();
            var serializer = new XmlSerializer(dtoType);
            serializer.Serialize(writer, dto);
            return writer.ToString();
        }
    }
}